package dataproviders;

import items.BrandDTO;
import items.Service;
import java.util.Iterator;
import java.util.List;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

@SuppressWarnings("serial")
public class BrandDataProvider implements IDataProvider{

	List<BrandDTO> brandsmodels;
	
	public BrandDataProvider(List<BrandDTO> brandsmodels){
		super();
		this.brandsmodels = brandsmodels;
	}
	
	@Override
	public void detach() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Iterator iterator(int first, int count) {
		return this.brandsmodels.subList(first, first + count).iterator();
	}

	@Override
	public int size() {
		return this.brandsmodels.size();
	}

	@Override
	public IModel model(Object object) {
		 int index = this.brandsmodels.indexOf(object);
		   return new PropertyModel<Service>(this.brandsmodels, String.valueOf(index));
	}

}
